import AMISEditor from "@/components/AMISEditor";
import {useParams} from "react-router-dom";
import {useRequest} from "ahooks";
import {getMenuSchema} from "@/services/menu";
import {PageLoading} from "@ant-design/pro-layout";

const SchemaEditor : React.FC = () => {
    const routeParams = useParams();
    console.log('---SchemaEditor-->',routeParams)
    const {data,loading} = useRequest(getMenuSchema,{
        ready: !!routeParams.id,
        refreshDeps: [routeParams.id],
        onBefore: (params) => {
            console.log('AdminSchema onBefore',routeParams)
            // @ts-ignore
            params[0] = routeParams.id;
        },
    });
    return <div>
        {loading?<PageLoading/>:<AMISEditor schema={data?JSON.parse(data?.data.data):{}}/>}
    </div>
};

export default SchemaEditor;